package pro1_10.pro2;

public class myStack {

    private int[] data;
    private int[] min;
    private int pop;
    private int size;

    public myStack(int size){
        data = new int[size];
        min = new int[size];
        pop = 0;
        size = size;
    }

    public int pop(){
        int a = min[pop];
        pop = pop - 1;
        return a;
    }

    public void push(int value){
        if(pop == size - 1){
            System.out.println("满");
        }
        if(pop == 0){
            data[pop] = value;
            min[pop] = value;
            pop += 1;
        }else {
            data[pop] = value;
            if(value < min[pop-1]){
                min[pop] = value;
            }else {
                min[pop] = min[pop-1];
            }
            pop = pop + 1;
        }
    }

    public int getMin(){
        return min[pop-1];
    }

}
